#include"Btree.h"
#include<assert.h>
BTNode* BuyNewNode(BTDataType x) {
	BTNode* new = (BTNode*)malloc(sizeof(BTNode));
	assert(new);
	new->data = x;
	new->left = new->right = NULL;
	return new;
}
BTNode* CreateNewTree() {
	BTNode* root = BuyNewNode(1);
	BTNode* new1 = BuyNewNode(2);
	BTNode* new2 = BuyNewNode(3);
	BTNode* new3 = BuyNewNode(4);
	BTNode* new4 = BuyNewNode(5);
	BTNode* new5 = BuyNewNode(6);
	BTNode* new6 = BuyNewNode(7);
	BTNode* new7 = BuyNewNode(8);
	root->left = new1;
	root->right = new2;
	new1->left = new3;
	new1->right = new4;
	new2->left = new5;
	new3->left = new7;
	new3->right = new6;

	return root;
}

int main(){
	BTNode*root=CreateNewTree();
	printf("leafsize=%d \n", TreeLeafSize(root));
	printf("7Nodedata=%d \n", TreeFind( root, 7)->data);
	printf("treedepth=%d \n", TreeDepth(root));
	printf("treesize=%d \n", BinaryTreeSize(root));
	printf("treeK(3)size=%d\n", BinaryTreeLevelKSize(root, 3));
	BinaryTreePrevOrder(root);
	printf("\n");
	BinaryTreeInOrder(root);
	printf("\n");
	BinaryTreePostOrder(root);
	printf("\n");
	BinaryTreeLevelOrder(root);
	printf("\n");
	if (BinaryTreeComplete(root))
		printf("BinaryTreeComplete=true\n");
	else
		printf("BinaryTreeComplete=false\n");

	BinaryTreeDestory(&root);
	root = NULL;
	printf("treesize=%d \n", BinaryTreeSize(root));
}